package com.foreknow.springboot.controller;

import com.foreknow.springboot.po.User;
import com.foreknow.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaoming
 * @version jdk1.8
 * @date 2022/8/13 22:08
 * @function:
 */
@RestController
@RequestMapping("/UserController")
public class UserController {
    @Autowired
    private UserService userService;

    //http://localhost:8089/elm/UserController/getUserByIdByPass?userId=12345&password=444
    @RequestMapping("/getUserByIdByPass")
    public User getUserByIdByPass(User user) {
        return userService.getUserByIdByPass(user.getUserId(),user.getPassword());
    }

    //http://localhost:8089/elm/UserController/getUserById?userId=12345
    @RequestMapping("/getUserById")
    public int getUserById(User user) {
        return userService.getUserById(user.getUserId());
    }

    //http://localhost:8089/elm/UserController/saveUser?userId=111&password=222&userName=aaa&userSex=1
    @RequestMapping("/saveUser")
    public int saveUser(User user) {
        return userService.saveUser(user.getUserId(),user.getPassword(),user.getUserName(),user.getUserSex());
    }
}
